#ifndef __Thread_H__
#define __Thread_H__

typedef void(*ThreadFunc)(void*);

class Thread
{
private:
	typedef struct __tag_ThreadInfo
	{
		ThreadFunc pFunc;
		void * pData;
		__tag_ThreadInfo(ThreadFunc func, void * data) : 
			pFunc(func), pData(data) 
		{
		};
	} ThreadInfo;

	static void * _ThreadMain(void * threadParam);

	void * tHandle;
	ThreadInfo sThreadParam;

	Thread(const Thread&);
	Thread& operator=(const Thread&);
public:
	Thread(ThreadFunc func, void * data = NULL);
	~Thread();

	bool Cancel();
	bool Kill(int signal);
	bool Join();

	static void ForceSwitch();
	static void TestCancel();
	static void ProtectFromCancel(bool protect);
};

#endif

